﻿using System.Data.SqlClient;
using NUnit.Framework;
using Pantry.Entity;
using Pantry.DataAccess;
namespace Pantry.UnitTest
{
    [TestFixture]
    public class TestTypeOfBusinessDao
    {
        [Test]
        public void TestReturnSearchValue_NullValue()
        { const string connection = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
            var sqlconnect = new SqlConnection(connection);
            var typeOfBusiness = new TypeOfBusinessSearch { TypeName = "", SicCode = "" };
            var dataView = new TypeOfBusinessSearchDao().ReturnSearchValue(typeOfBusiness.TypeName, typeOfBusiness.SicCode, sqlconnect);
            Assert.AreEqual(null,dataView);            
        }
        [Test]
        public void TestReturnSearchValue_ValidValue()
        {
            const string connection = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
            var sqlconnect = new SqlConnection(connection);
            var typeOfBusiness = new TypeOfBusinessSearch { TypeName = "", SicCode = "1234" };
            var dataView = new TypeOfBusinessSearchDao().ReturnSearchValue(typeOfBusiness.TypeName, typeOfBusiness.SicCode, sqlconnect);
            Assert.IsNotEmpty(dataView.Table.Rows.Count.ToString());
        }
        [Test]
        public void TestReturnSearchValue_FullValue()
        {
            const string connection = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
            var sqlconnect = new SqlConnection(connection);
            var typeOfBusiness = new TypeOfBusinessSearch { TypeName = "abc", SicCode = "1234" };
            var dataView = new TypeOfBusinessSearchDao().ReturnSearchValue(typeOfBusiness.TypeName, typeOfBusiness.SicCode, sqlconnect);
            Assert.IsNotEmpty(dataView.Table.Rows.Count.ToString());
        }
    }
}
